$(function () {
    $('.recharge-order-btn').click(function (event) {
        var self = $(this);
        var tr = self.parent().parent();
        var order_id = tr.attr('data-id');
        zlalert.alertConfirm({
            'msg':'您确定要完成订单吗？',
            'confirmCallback':function () {
                zlajax.post({
                    'url':'/manage/buy_order_success/',
                    'data':{
                        'order_id':order_id
                    },
                    'success':function (data){
                        if(data['code']==200){
                            window.location.reload()
                        }else{
                            const timer =setInterval(() => {
                                  zlalert.alertError(data['message']);
                                  clearInterval(timer);

                                }, 100);
                        }
                    }
                })
            }
        })
    })
});




$(function () {
    $('.recharge-cancel-btn').click(function (event) {
        var self = $(this);
        var tr = self.parent().parent();
        var order_id = tr.attr('data-id');
        zlalert.alertConfirm({
            'msg':'您确定要取消订单吗？',
            'confirmCallback':function () {
                zlajax.post({
                    'url':'/manage/buy_order_cancel/',
                    'data':{
                        'order_id':order_id
                    },
                    'success':function (data) {
                        if(data['code']==200){
                            window.location.reload()
                        }else{
                            const timer =setInterval(() => {
                                  zlalert.alertError(data['message']);
                                  clearInterval(timer);

                                }, 100);
                        }
                    }
                })
            }
        })
    })
});


$(function () {
    $('.order-return-btn').click(function (event) {
        var self = $(this);
        var tr = self.parent().parent();
        var order_id = tr.attr('data-id');
        zlalert.alertConfirm({
            'msg':'您确定要完成订单吗？',
            'confirmCallback':function () {
                zlajax.post({
                    'url':'/manage/check_order_return/',
                    'data':{
                        'order_id':order_id
                    },
                    'success':function (data){
                        if(data['code']==200){
                            window.location.reload()
                        }else{
                            const timer =setInterval(() => {
                                  zlalert.alertError(data['message']);
                                  clearInterval(timer);

                                }, 100);
                        }
                    }
                })
            }
        })
    })
});
